﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>字典明细管理</title>
    <#include "../common/link.ftl"/>

</head>
<script>
    $(function () {
        $(".btn-input").click(function () {
            //清空表单数据
            $("#editForm input").val('');
            //找到绑定这个事件的标签,获取这个标签的data前缀,json为后缀的属性的值
            var json = $(this).data('json');
            //数据回显
            if(json){
                $("#editForm input[name=id]").val(json.id);
                $('#systemdictionaryId').val(json.systemdictionaryId);
                $("#editForm input[name=title]").val(json.title);
                $("#editForm input[name=sequence]").val(json.sequence);
                //标题改为编辑
                $('#myModalLabel').html("编辑操作")
            }else{
                $('#myModalLabel').html("新增操作")
            }
            //弹出模态框
            $('#myModal').modal('show');
        })

        //保存按钮进行的操作
        $("#saveOrUpdateButton").click(function () {
            //将表单转为异步请求,并且马上提交请求
            $("#editForm").ajaxSubmit(function (data) {
                $.messager.confirm("温馨提示",data.msg,function () {
                    window.location.reload();
                })
            });
        });

        //给字典目录的数据绑定事件,点击的时候就到后台查询对应目录下的数据
        $("#parentId li").click(function () {

             var val = $(this).val();
             $('[name="parentId"]').val(val);
             $("#searchForm").submit();
        });
    });

</script>


<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <<#assign currentMenu='systemDictionaryItem'>
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>字典明细管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <div class="row box-body">
                    <div class="col-md-3">
                        <ul id="parentId" class="list-group">
                            <#list systemDictionaries as systemDictionary>
                                <li class="list-group-item ${(qo.parentId?? && qo.parentId ==  systemDictionary.id)?string('active', '')}" value="${systemDictionary.id}">${systemDictionary.title}</li>
                            </#list>
                        </ul>
                    </div>
                    <div class="col-md-9">
                        <!--高级查询--->
                        <form class="form-inline" id="searchForm" action="/systemDictionaryItem/list.do" method="post">
                            <input type="hidden" name="currentPage" id="currentPage" value="1">
                            <input type="hidden"  name="parentId" value="${(qo.parentId)!}">
                            <#if qo.parentId??>
                                 <a data-url="/systemDictionaryItem/input.do" class="btn btn-success btn-input">
                                     <span class="glyphicon glyphicon-plus"></span> 添加
                                 </a>
                            </#if>
                        </form>
                        <!--编写内容-->
                        <div class="table-responsive no-padding ">
                            <table class="table table-hover table-bordered">
                                <tr>
                                    <th>编号</th>
                                    <th>字典目录</th>
                                    <th>标题</th>
                                    <th>序列</th>
                                    <th>操作</th>
                                </tr>

                                <#list pageResult.list as systemDictionaryItem>
                                    <tr>
                                        <td>${systemDictionaryItem_index + 1}</td>
                                        <td>${(systemDictionaryItem.systemdictionary.title)!}</td>
                                        <td>${systemDictionaryItem.title}</td>
                                        <td>${systemDictionaryItem.sequence}</td>
                                        <td>
                                            <#if qo.parentId??>
                                                 <a data-json='${systemDictionaryItem.jsonData}' class="btn btn-info btn-xs btn-input">
                                                     <span class="glyphicon glyphicon-pencil"></span> 编辑
                                                 </a>
                                            </#if>
                                            <a data-url="/systemDictionaryItem/delete.do" data-id="${systemDictionaryItem.id}" data-list="/systemDictionaryItem/list.do"
                                               class="btn btn-danger btn-xs btn-delete">
                                                <span class="glyphicon glyphicon-trash"></span> 删除
                                            </a>
                                        </td>
                                    </tr>
                                </#list>
                            </table>
                            <!--分页-->
                            <#include "../common/page.ftl">
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>
<#--新增/编辑模态框-->

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">新增/编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/systemDictionaryItem/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden"  name="id">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-3 control-label">字典目录：</label>
                        <div class="col-sm-6">
                            <select name="systemdictionary.id" class="form-control">
                                <#list systemDictionaries as systemDictionary>
                                    <option value="${systemDictionary.id}" <#if (qo.parentId?? && (qo.parentId==systemDictionary.id))>selected</#if>>${systemDictionary.title}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="title" class="col-sm-3 control-label">标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="title" name="title">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sequence" class="col-sm-3 control-label">序列：</label>
                        <div class="col-sm-6">
                            <input type="number" min="1" class="form-control" id="sequence" name="sequence">
                        </div>
                    </div>
            </div>
            <div class="modal-footer">
                <button id="saveOrUpdateButton" type="button" class="btn btn-primary">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

</body>
</html>
